$(function(){
	$.ajax({
		type : 'POST',
		url :path+"/admin/getSystemSetUpDateil.htm",
		data : {},
		dataType : 'json',
		success : function(data) {
			console.log(data);
			if (data.m_istatus == 1) {
				$('#t_id').val(data.m_object.t_id);
				$('#t_scope').val(data.m_object.t_scope);
				$('#t_android_download').val(data.m_object.t_android_download);
				$('#t_ios_download').val(data.m_object.t_ios_download);
				$('#t_system_lang_girl').val(data.m_object.t_system_lang_girl);
				$('#t_system_lang_male').val(data.m_object.t_system_lang_male);
				$('#t_default_phone').val(data.m_object.t_default_phone);
				$('#t_default_text').val(data.m_object.t_default_text);
				$('#t_default_video').val(data.m_object.t_default_video);
				$('#t_default_voice').val(data.m_object.t_default_voice);
				$('#t_default_weixin').val(data.m_object.t_default_weixin);
				$('#t_default_qq').val(data.m_object.t_default_qq);
				$('#t_award_rules').val(data.m_object.t_award_rules);
				$('#t_service_qq').val(data.m_object.t_service_qq);
				$('#t_service_wx').val(data.m_object.t_service_wx);
				$('#t_video_hint').val(data.m_object.t_video_hint);
				$('#t_spreed_hint').val(data.m_object.t_spreed_hint);
				$('#t_nickname_filter').val(data.m_object.t_nickname_filter);
				$('#t_first_prize').val(data.m_object.t_first_prize);
				$('#t_fail_gold').val(data.m_object.t_fail_gold);
				$('#t_default_pay').val(data.m_object.t_default_pay);
				//用户拨打开关
				$('#t_dial_video').val(data.m_object.t_dial_video);
				//主播拨打开关
				$('#t_dial_anchor_video').val(data.m_object.t_dial_video);
				
				$('#t_answer_video').val(data.m_object.t_answer_video);
				$('#t_h5_pay_url').val(data.m_object.t_h5_pay_url);

				$('#t_false_send_video_switch').val(data.m_object.t_false_send_video_switch);
				$('#t_all_false_send_video_switch').val(data.m_object.t_all_false_send_video_switch);
				$('#t_false_send_text_switch').val(data.m_object.t_false_send_text_switch);
//				    $('#t_real_send_text_switch').val(data.m_object.t_real_send_text_switch);

				$('#t_sound_recording_switch').val(data.m_object.t_sound_recording_switch);

				$('#t_false_send_text_switch_count').val(data.m_object.t_false_send_text_switch_count);

				$('#t_screenshot_user_switch').val(data.m_object.t_screenshot_user_switch);
				$('#t_screenshot_anchor_switch').val(data.m_object.t_screenshot_anchor_switch);
				$('#t_screenshot_time_list').val(data.m_object.t_screenshot_time_list);
				$('#t_private_letter_number').val(data.m_object.t_private_letter_number);
				$('#t_free_svip').val(data.m_object.t_free_svip);
				$('#t_minute_svip').val(data.m_object.t_minute_svip);
				$('#t_screenshot_video_switch').val(data.m_object.t_screenshot_video_switch);
				$('#t_language_switch').val(data.m_object.t_language_switch);
				
			} else  {
				window.location.href = path + '/error.html';
			}
		}
	});
});



/*提交数据*/
function on_click_submit(){
	var obj =  [
		{'name':'t_scope','type':'int'},
		{'name':'t_android_download','type':'string'},
		{'name':'t_ios_download','type':'string'},
		{'name':'t_system_lang_girl','type':'string'},
		{'name':'t_system_lang_male','type':'string'},
		{'name':'t_default_text','type':'int'},
		{'name':'t_default_video','type':'int'},
		{'name':'t_default_voice','type':'int'},
		{'name':'t_default_weixin','type':'string'},
		{'name':'t_default_qq','type':'string'},
		{'name':'t_award_rules','type':'string'},
		{'name':'t_dial_video','type':'String'},
		{'name':'t_dial_anchor_video','type':'String'},
		{'name':'t_answer_video','type':'String'},
		{'name':'t_false_send_video_switch','type':'String'},
//		   {'name':'t_all_false_send_video_switch','type':'String'},
		{'name':'t_false_send_text_switch','type':'String'},
//		   {'name':'t_real_send_text_switch','type':'String'},
		{'name':'t_false_send_text_switch_count','type':'String'},
		{'name':'t_sound_recording_switch','type':'String'},

		{'name':'t_screenshot_user_switch','type':'String'},
		{'name':'t_screenshot_anchor_switch','type':'String'},
		{'name':'t_screenshot_time_list','type':'String'},
		{'name':'t_h5_pay_url','type':'String'},

		{'name':'t_service_qq','type':'string'},
		{'name':'t_service_qq','type':'string'},
		{'name':'t_private_letter_number','type':'string'},
		{'name':'t_free_svip','type':'int'},
		{'name':'t_minute_svip','type':'int'},
		{'name':'t_language_switch','type':'int'}

	];
	if($('#t_default_phone').val() == null){
		$("#t_default_phone").css({ "border-color": "red" });
		$('#t_default_phone_validate').empty();
		$('#t_default_phone_validate').append('<i style="margin-top: 10px;" class="glyphicon glyphicon-remove">请输入查看手机号的默认值</i>');
		return;
	}
	if($('#t_fail_gold').val() == null || $('#t_fail_gold').val() == '' || $('#t_fail_gold').val() < 0){
		$("#t_fail_gold").css({ "border-color": "red" });
		$('#t_fail_gold_validate').empty();
		$('#t_fail_gold_validate').append('<i style="margin-top: 10px;" class="glyphicon glyphicon-remove">请输入低于多少金币后无法呼叫主播.</i>');
		return;
	}
	if($('#t_default_voice').val() == null || $('#t_default_voice').val() == '' || $('#t_default_voice').val() < 0){
		$("#t_default_voice").css({ "border-color": "red" });
		$('#t_default_voice_validate').empty();
		$('#t_default_voice_validate').append('<i style="margin-top: 10px;" class="glyphicon glyphicon-remove">请输入默认语音聊天收费.</i>');
		return;
	}
	if($('#t_first_prize').val() == null || $('#t_first_prize').val() == '' || $('#t_first_prize').val() < 0){
		$("#t_first_prize").css({ "border-color": "red" });
		$('#t_first_prize_validate').empty();
		$('#t_first_prize_validate').append('<i style="margin-top: 10px;" class="glyphicon glyphicon-remove">请输入推广用户首次充值赠送多少金币</i>');
		return;
	}



	if(vaildate_is_submit(obj)){
		$.ajax({
			type : 'POST',
			url : path + "/admin/setSystemSetUp.htm",
			data : {
				t_id:$('#t_id').val(),
				t_scope:$('#t_scope').val(),
				t_android_download:$('#t_android_download').val(),
				t_ios_download:$('#t_ios_download').val(),
				t_system_lang_girl:  $('#t_system_lang_girl').val(),
				t_system_lang_male:$('#t_system_lang_male').val(),
				t_default_text:$('#t_default_text').val(),
				t_default_video:$('#t_default_video').val(),
				t_default_voice:$('#t_default_voice').val(),
				t_default_phone:$('#t_default_phone').val(),
				t_default_weixin:$('#t_default_weixin').val(),
				t_default_qq:$('#t_default_qq').val(),
				t_award_rules:$('#t_award_rules').val(),
				t_service_qq:$('#t_service_qq').val(),
				t_service_wx:$('#t_service_wx').val(),
				t_nickname_filter:$('#t_nickname_filter').val(),
				t_video_hint:$('#t_video_hint').val(),
				t_spreed_hint:$('#t_spreed_hint').val(),
				t_fail_gold:$('#t_fail_gold').val(),
				t_first_prize:$('#t_first_prize').val(),
				t_answer_video:$('#t_answer_video').val(),
				t_dial_video:$('#t_dial_video').val(),
				t_dial_anchor_video:$('#t_dial_anchor_video').val(),
				t_h5_pay_url:$('#t_h5_pay_url').val(),


				t_false_send_video_switch:$('#t_false_send_video_switch').val(),
				t_all_false_send_video_switch:$('#t_all_false_send_video_switch').val(),

				t_real_send_text_switch:0,
				t_false_send_text_switch:$('#t_false_send_text_switch').val(),
				t_false_send_text_switch_count:$('#t_false_send_text_switch_count').val(),
				t_sound_recording_switch:$('#t_sound_recording_switch').val(),

				t_screenshot_user_switch:$('#t_screenshot_user_switch').val(),
				t_screenshot_anchor_switch:$('#t_screenshot_anchor_switch').val(),
				t_screenshot_time_list:$('#t_screenshot_time_list').val(),
				t_private_letter_number:$('#t_private_letter_number').val(),

				t_default_pay:$('#t_default_pay').val(),
				t_free_svip:$('#t_free_svip').val(),
				t_minute_svip:$('#t_minute_svip').val(),
				t_screenshot_video_switch:$('#t_screenshot_video_switch').val(),
				t_language_switch:$('#t_language_switch').val()
			},
			dataType : 'json',
			success : function(data) {
				if (data.m_istatus != 0) {
					$('#my_comfirm').empty();
					$('#my_comfirm').append(data.m_strMessage);
					$('#myComfirm').modal('show');
				} else {
					window.location.href = path + '/error.html';
				}
			}
		});
	}
}